export const getNow = () => {
  function _p(s) {
    return s < 10 ? '0' + s : s
  }

  let myDate = new Date()
  //获取当前年
  let year = myDate.getFullYear()
  //获取当前月
  let month = myDate.getMonth() + 1
  //获取当前日
  let date = myDate.getDate()
  let h = myDate.getHours() //获取当前小时数(0-23)
  let m = myDate.getMinutes() //获取当前分钟数(0-59)
  let s = myDate.getSeconds()

  let nowDate = year + '/' + _p(month) + '/' + _p(date)
  let nowTime = _p(h) + ':' + _p(m) + ':' + _p(s)

  return { nowDate, nowTime }
}

export const isMobile = () => {
  // 宽度是1366
  if (window.innerWidth <= 1366) {
    return true
  }

  let userAgentInfo = navigator.userAgent
  let Agents = [
    'Android',
    'iPhone',
    'SymbianOS',
    'Windows Phone',
    'iPad',
    'iPod',
    'applewebkit',
  ]
  let getArr = Agents.filter((i) => userAgentInfo.includes(i))
  return getArr.length ? true : false
}

// 删除页面内所有 class 为 orbit-controls 的元素
export const removeOrbitControls = () => {
  const orbitControls = document.querySelectorAll('.orbit-controls')
  orbitControls.forEach((item) => {
    item.remove()
  })
}
